ARG image=lavasoftware/lava-dispatcher:latest
FROM ${image}

ARG extra_packages=""
RUN sed -i '/^Components:/ s/$/ non-free/' /etc/apt/sources.list.d/debian.sources
RUN apt-get -q update
RUN DEBIAN_FRONTEND=noninteractive apt-get -q -y install ${extra_packages} net-tools nfs-common snmp snmp-mibs-downloader
RUN download-mibs

# Add MIBs
RUN mkdir -p /usr/share/snmp/mibs/
ADD mibs/* /usr/share/snmp/mibs/

# Add certificates.
COPY certs/* /etc/lava-dispatcher/certificates.d/

# Add ssh config.
COPY ssh/* /root/.ssh/

# Add power control scripts.
COPY power-control/* /root/power-control/

# Add LAVA coordinator config (required for multinode jobs).
RUN mkdir -p /etc/lava-coordinator
COPY lava-coordinator.conf /etc/lava-coordinator/

# Add lab scripts
RUN mkdir -p /usr/local/lab-scripts/
ADD https://git.linaro.org/lava/lava-lab.git/plain/shared/lab-scripts/snmp_pdu_control /usr/local/lab-scripts/
RUN chmod a+x /usr/local/lab-scripts/snmp_pdu_control
ADD https://git.linaro.org/lava/lava-lab.git/plain/shared/lab-scripts/eth008_control /usr/local/lab-scripts/
RUN chmod a+x /usr/local/lab-scripts/eth008_control

ENTRYPOINT ["/root/entrypoint.sh"]
